import Vue from 'vue'
import VueRouter from 'vue-router'
// import home from '../components/home'
// import test from '../components/pages/test'
import App from '../App'
const home = (r) =>
  require.ensure([], () => r(require('../components/home')), 'home')
const category = (r) =>
  require.ensure(
    [],
    () => r(require('../components/pages/category')),
    'tcategoryest'
  )
const hotSearch = (r) =>
  require.ensure(
    [],
    () => r(require('../components/base/hotSearch')),
    'hostSearch'
  )
const searchResultList = (r) =>
  require.ensure(
    [],
    () => r(require('../components/base/searchResultList')),
    'searchResultList'
  )
const scrollLoadmore = (r) =>
  require.ensure(
    [],
    () => r(require('../components/base/scrollLoadmore')),
    'scrollLoadmore'
  )
const login = (r) =>
  require.ensure([], () => r(require('../components/pages/login')), 'login')
const ranking = (r) =>
  require.ensure([], () => r(require('../components/pages/ranking')), 'ranking')
const my = (r) =>
  require.ensure([], () => r(require('../components/pages/my')), 'my')
const productDetails = (r) =>
  require.ensure(
    [],
    () => r(require('../components/pages/productDetails')),
    'productDetails'
  )
const shopingCart = (r) =>
  require.ensure(
    [],
    () => r(require('../components/pages/shopingCart')),
    'shopingCart'
  )
// const testLoadmore = (r) =>
//   require.ensure(
//     [],
//     () => r(require('../components/base/testLoadmore')),
//     'testLoadmore'
//   )
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: App,
    children: [
      {
        path: '',
        redirect: '/home',
      },
      {
        path: '/home',
        component: home,
      },
      {
        path: '/category',
        component: category,
      },
      {
        path: '/hotSearch',
        component: hotSearch,
      },
      {
        path: '/searchResultList',
        component: searchResultList,
      },
      {
        path: '/scrollLoadmore',
        component: scrollLoadmore,
      },
      {
        path: '/login',
        component: login,
      },
      {
        path: '/ranking',
        component: ranking,
      },
      {
        path: '/my',
        component: my,
      },
      {
        path: '/productDetails',
        component: productDetails,
      },
      {
        path: '/shopingCart',
        component: shopingCart,
      },
      // {
      //   path: '/testLoadmore',
      //   component: testLoadmore,
      // },
    ],
  },
  // {
  //   path: '/',
  //   redirect: '/home',
  // },
  // {
  //   path: '/home',
  //   component: home,
  //   // children: [
  //   //   {
  //   //     path: '/test',
  //   //     component: test,
  //   //   },
  //   // ],
  // },
  // {
  //   path: '/test',
  //   component: test,
  // },
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () =>
  //     import(/* webpackChunkName: "about" */ '../views/About.vue'),
  // },
]

const router = new VueRouter({
  routes,
  mode: 'hash',
})

export default router
